package com.wc.算法基础课.C第三讲搜索与图论.染色法判定二分图.染色法判定二分图;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/4/15 15:48
 * @description https://www.acwing.com/activity/content/punch_the_clock/11/
 */
public class Main {
    /**
     * 染色法
     * 二分图： 可以将图中的所有节点, 分成两个集合, 只有集合和集合之间的点可以被边连接, 集合内部没有点被连接
     * 性质：二分图不含有奇数个数的环
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, M = N << 1;
    static int[] h = new int[N], e = new int[M], ne = new int[M];
    static int idx = 1;
    // 判断当前点是否被染色
    static int[] st = new int[N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        while (m-- > 0) {
            int a = sc.nextInt(), b = sc.nextInt();
            add(a, b);
            add(b, a);
        }
        boolean flg = true;
        for (int i = 1; i <= n; i++) {
            if (st[i] == 0) {
                if (!dfs(i, 1)) flg = false;
            }
        }
        if (flg) out.println("Yes");
        else out.println("No");
        out.flush();
    }

    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }

    static boolean dfs(int u, int c) {
        st[u] = c;
        for (int i = h[u]; i > 0; i = ne[i]) {
            int j = e[i];
            if (st[j] == 0) {
                if (!dfs(j, 3 - c)) return false;
            } else if (st[j] == c) return false;
        }
        return true;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
